<template>
  <div class="dashboard-container">
    <el-row>
      <el-col :span="24"><div class="dashboard-text">信息概览</div></el-col>
    </el-row>
    <el-row>
      <el-col :span="24"><br><hr><br><br></el-col>
    </el-row>
    <el-row>
      <el-col :span="4">
        <div>
          <i class="el-icon-sell" style="font-size: 100px;"></i>
          <br>
          <el-badge :value="overview.amQty" class="item">
            <el-button size="big" style="font-size: 15px">申领单数</el-button>
          </el-badge>
        </div>
      </el-col>
      <el-col :span="4">
        <div>
          <i class="el-icon-box" style="font-size: 100px;"></i>
          <br>
          <el-badge :value="overview.rmQty" class="item">
            <el-button size="big" style="font-size: 15px">归还单数</el-button>
          </el-badge>
        </div>
      </el-col>
      <el-col :span="4">
        <div>
          <i class="el-icon-document" style="font-size: 100px;"></i>
          <br>
          <el-badge :value="overview.pmQty" class="item">
            <el-button size="big" style="font-size: 15px">采购单数</el-button>
          </el-badge>
        </div>
      </el-col>
      <el-col :span="4">
        <div>
          <i class="el-icon-s-goods" style="font-size: 100px;"></i>
          <br>
          <el-badge :value="overview.inQty" class="item">
            <el-button size="big" style="font-size: 15px">入库单数</el-button>
          </el-badge>
        </div>
      </el-col>
      <el-col :span="4">
        <div>
          <i class="el-icon-goods" style="font-size: 100px;"></i>
          <br>
          <el-badge :value="overview.outQty" class="item">
            <el-button size="big" style="font-size: 15px">出库单数</el-button>
          </el-badge>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col></el-col>
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getOverview } from '@/api/analysis'

// 注意要想用 token 中放置的一些数据，需要更改 store 目录下的 getters.js、user.js 文件增加对应登录时jwt token 所存放的数据
export default {
  name: 'OverView',
  computed: {
    ...mapGetters([
      'name',
      'id'
    ])
  },
  data () {
    return {
      overview: {}  
    }
  },
  created () {
    getOverview().then(response => {
      this.overview = response.data.overview
    })
  }
}
</script>

<style lang="scss" scoped>
  .dashboard {
    &-container {
      margin: 30px;
    }

    &-text {
      font-size: 30px;
      line-height: 46px;
    }
  }
</style>
